﻿using System;
using System.Collections;

public class MenuProvider
{
    public SortedList Attributer = new SortedList();
    public SortedList Location = new SortedList();
    public SortedList Target = new SortedList();

    public MenuProvider()
    {
        this.LocationLoad();
        this.AttributerLoad();
        this.TargetLoad();
    }

    protected void AttributerLoad()
    {
        this.Attributer.Add("0", "单页图文");
        this.Attributer.Add("1", "新闻文章");
        this.Attributer.Add("2", "图文展示");
        //this.Attributer.Add("3", "商品展示");
        //this.Attributer.Add("4", "留言反馈");
        this.Attributer.Add("900", "网站首页");
        this.Attributer.Add("901", "外部链接");
    }

    public static string FormatContentManagerUrl(string attribute, string menuId)
    {
        Hashtable hashtable = new Hashtable();
        hashtable.Add("0", "Page.aspx");
        hashtable.Add("1", "Article.aspx");
        hashtable.Add("2", "Pic.aspx");
        hashtable.Add("3", "Product.aspx");
        hashtable.Add("4", "Message.aspx");
        hashtable.Add("900", "SiteIndex.aspx");
        string str = hashtable[attribute].ToString();
        return string.Format("{0}?menuId={1}", str, menuId);
    }

    public static string FormatMenuUrl(string attribute)
    {
        Hashtable hashtable = new Hashtable();
        hashtable.Add("0", "Page");
        hashtable.Add("1", "Article");
        hashtable.Add("2", "Pic");
        hashtable.Add("3", "Product");
        hashtable.Add("4", "Message");
        hashtable.Add("900", "SiteIndex");
        return hashtable[attribute].ToString();
    }

    public static string GetAttributer(string key)
    {
        MenuProvider provider = new MenuProvider();
        return provider.Attributer[key].ToString();
    }

    public static string GetLocation(string key)
    {
        MenuProvider provider = new MenuProvider();
        return provider.Location[key].ToString();
    }

    public static string GetTarget(string key)
    {
        MenuProvider provider = new MenuProvider();
        return provider.Target[key].ToString();
    }

    protected void LocationLoad()
    {
        this.Location.Add("0", "主栏目");
        this.Location.Add("1", "顶部栏目");
        this.Location.Add("2", "底部栏目");
    }

    protected void TargetLoad()
    {
        this.Target.Add("_self", "原窗口");
        this.Target.Add("_blank", "新窗口");
    }
}

